import java.util. *;
import java.io. *;
import java.util.Scanner;

/*public class Main{
    //去掉文件中多余的空格并将首字母都大写
    public static void main1(String[] args) {
        try {
            Scanner sc=new Scanner(new File("E:\\比特就业课\\javaSE\\J20230418\\ld.txt"));
            while(sc.hasNextLine()){

                String s=sc.nextLine();
                //System.out.println (s);
                String[] aa=s.split("\\s+");
                StringBuilder total=new StringBuilder();
                for(String ss: aa){
                    total.append(ss.substring(0,1).toUpperCase()+ss.substring(1)+" ");

                }
                System.out.println (total);
            }
        }
        catch (Exception ex) {
        }
    }
}*/
public class Main {

    public static void mn(String[] args) {
        char[] array = new char[10];

        double[] array2 = new double[10];

        boolean[] array3 = new boolean[10];

        String[] strings = new String[10];
    }

    public static void tt(String[] args) {
        int[] array1 = {1, 2, 3, 4};

        int[] array2 = new int[10];//定义了一个大小为10的整型数组

        int[] array3 = new int[]{1, 2, 3, 4, 5, 6, 7};

        System.out.println(array1);
        System.out.println(array2);
        System.out.println(array3);

        int[] array4;
        array4 = new int[10];

        int[] array5;
        array5 = new int[]{1, 2, 3, 4, 5};

       /* int[] array6;
        array6 = {1,2,3,4,5,6,7,8,9,0};*/
    }

        public static int add(int a,int b) {
        return a+b;
    }
    public static int add(int a,int b,int c,int d) {
        return a+b+c+d;
    }

    public static int add(int a,int b,int c) {
        return a+b+c;
    }

    public static int add(double a,double b) {
        return (int)(a+b);
    }

    public static int funFac(int n) {
        if(n == 1) {
            return 1;
        }/**/
        int tmp = n * funFac(n-1);
        return tmp;
    }

    public static void print(int n) {
        if(n < 10) {
            System.out.println(n);
            return;
        }
        //123
        print(n / 10);
        System.out.println(n % 10);
    }

    public static int sumN(int n) {
        if(n == 1) {
            return 1;
        }
        int tmp = n + sumN(n-1);
        return tmp;
    }

    public static int func(int n) {
        if(n < 10) {
            return n;
        }
        int tmp = func(n/10) + n%10;
        return tmp;
    }


    public static int count = 0;
    public static int fib(int n) {
        if(n == 1) {
            count++;
            return 0;
        }
        if(n == 2) {
            count++;
            return 1;
        }
        return fib(n-1) + fib(n-2);
    }

    public static int fib2(int n) {
        if(n == 1) {
            return 0;
        }
        if(n == 2) {
            return 1;
        }
        int f1 = 0;
        int f2 = 1;
        int f3 = -1;
        for (int i = 3; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }


    public static void main(String[] args) {
        /*System.out.println(fib(1));
        System.out.println(fib(2));
        System.out.println(fib(3));
        System.out.println(fib(4));
        System.out.println(fib(40));*/
        System.out.println(fib2(41));
        //System.out.println(count);
         /*System.out.println(func(123));
       System.out.println(funFac(5));
        int a = 10;
        int b = 20;
        System.out.println(add(a, b));

        double d1 = 12.5;
        double d2 = 22.5;
        System.out.println(add(d1, d2));
*/

    }



    public static void swap(int x,int y) {
        int tmp = x;
        x = y;
        y = tmp;
    }
    public static void main10(String[] args) {
        int a = 10;
        int b = 20;
        /*System.out.println(swap(10,0));
        int ret = swap(a,b);*/
        System.out.println(a+" "+ b);
    }



    public static void main9(String[] args) {
        int n = 5;
        System.out.println(facSum(n));
        /*int ret = fac(5);
        System.out.println(ret);
        */
        /*System.out.println(fac(5));
        System.out.println(fac(4));
        System.out.println(fac(6));*/
    }

    public static int facSum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += fac(i);
        }
        return sum;
    }

    public static int fac(int n) {
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }

    public static void main8(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("第一次调用方法之前");
        int ret = sum(a, b);
        System.out.println("第一次调用方法之后");
        System.out.println("ret = " + ret);
        System.out.println("第二次调用方法之前");
        ret = sum(30, 50);
        System.out.println("第二次调用方法之后");
        System.out.println("ret = " + ret);
    }
    public static int sum(int x, int y) {
        System.out.println("调用方法中 x = " + x + " y = " + y);
        return x + y;
    }



    public static void main7(String[] args) {
        //方法的调用
        boolean flg = isLeapYear(2014);
        System.out.println(flg);


        boolean flg2 = isLeapYear(1987);
        System.out.println(flg2);
    }

    public static boolean isLeapYear(int year) {
        if((0 == year % 4 && 0 != year % 100) || 0 == year % 400){
            //System.out.println(year+"年是闰年");
            return true;
        }
        return false;
    }

   /* public static int add(int a,int b) {
        return a+b;
    }*/

    public static void func() {
        System.out.println("func()");
    }

    public static void main6(String[] args) {
        int n = 7;
        /*for (int i = 0; i < 32 ; i += 2) {
            System.out.print(((n >> i)&1)+ " ");
        }*/
        /*for (int i = 30; i >= 0 ; i -= 2) {
            System.out.print(((n >> i)&1)+ " ");
        }
        System.out.println();
        for (int i = 31; i >= 0 ; i -= 2) {
            System.out.print(((n >> i)&1)+ " ");
        }*/

        int a = 24;
        int b = 18;
        int c = a % b;//6
        while (c != 0) {
            a = b;//18
            b = c;//6
            c = a % b;//
        }
        System.out.println(b);
    }

    public static void main5(String[] args) {
        Scanner in = new Scanner(System.in);

        int count = 3;
        while (count != 0) {
            System.out.println("请输入你的密码：你还有 "+ count+" 次机会！");
            String pass = in.nextLine();
            if(pass.equals("123456")) {
                System.out.println("登录成功！");
                break;
            }else {
                count--;
                System.out.println("密码错误！");
            }
        }
    }

    public static void main4(String[] args) {
        int n = 123;
        while (n != 0) {
            System.out.println(n%10);
            n /= 10;
        }
    }
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            for (int i = 0; i < a; i++) {
                for (int j = 0; j < a; j++) {
                    if(i == j || i+j == (a-1)){
                        System.out.print("*");
                    }else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }


    public static void main2(String[] args) {
        double sum = 0;
        int flg = 1;
        for (int i = 1; i <= 100; i++) {
            sum += 1.0/i*flg;
            flg = -flg;
        }
        System.out.println(sum);
    }
    public static void main1(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if(i / 10 == 9) {
                //十位是9
                count++;
            }
            if(i % 10 == 9) {
                //个位是9
                count++;
            }
        }
        System.out.println(count);
    }
}
